//
//  Extension_MediaPlay.swift
//  JMMediaTest
//
//  Created by Mengxuan Chen on 2019/1/15.
//  Copyright © 2019年 Mengxuan Chen. All rights reserved.
//

import Foundation
import CTMediator

typealias JMSelectUrlBlock = (String) -> ()

let JMTargetMoudle = "MediaPlay"
let JMCTMediatorTargetName = "JMMediaTest"

enum JMActionType:String {
    case JMOpenPlayMoudle = "openMediaPlayMoudle"
    case JMShowAddressList = "showAddressList"
}

extension CTMediator {
    
    func jm_openMediaPlayMoudle(_ url:String) {
        let param = [kCTMediatorParamsKeySwiftTargetModuleName:JMCTMediatorTargetName,
                     "url":url]
        performTarget(JMTargetMoudle, action: JMActionType.JMOpenPlayMoudle.rawValue, params: param, shouldCacheTarget: true)
    }
    
    func jm_showAddressList(_ selectUrlBlock:@escaping JMSelectUrlBlock) {
        let param = [kCTMediatorParamsKeySwiftTargetModuleName: JMCTMediatorTargetName,
                     "selectUrlBlock":selectUrlBlock] as [String : Any]
        performTarget(JMTargetMoudle, action: JMActionType.JMShowAddressList.rawValue, params: param, shouldCacheTarget: true)
    }
}

